package offer;

/**
 * @Author Elephas
 * @Date 2022/2/4
 **/
public interface CountGoodRectangles {
    int countGoodRectangles(int[][] rectangles);
}
class CountGoodRectanglesImpl1 implements CountGoodRectangles{
    @Override
    public int countGoodRectangles(int[][] rectangles)  {
        int maxLen = 0;
        int maxLenFreq = 1;
        for(int i = 0; i < rectangles.length; i++){
            int[] rectangle = rectangles[i];
            int length = rectangle[0];
            int width = rectangle[1];
            int minArea = Math.min(length,width);
            if(minArea > maxLen){
                maxLen = minArea;
                maxLenFreq = 1;
            }else if(minArea == maxLen){
                maxLenFreq++;
            }
        }
        return maxLenFreq;
    }
}
